package com.toolsder.demo.spring.security.jwt.entity.database;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Set;

/**
 * created by Qk on 2020/2/2
 * 用户
 *
 * @author by 猴子请来的逗比
 */
@Entity
@Data
@NoArgsConstructor
@Accessors(chain = true)
public class User implements Serializable {

    private static final long serialVersionUID = 6994971121791385931L;
    /**
     * 主键
     */
    @Id
    private Long id;

    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * 创建日期
     */
    @Column(nullable = false)
    private LocalDateTime createTime;

    /**
     * 更新日期
     */
    @Column(nullable = false)
    private LocalDateTime updateTime;


    /**
     * 用户角色列表
     */
    @ManyToMany
    @JoinTable(name = "user_role",
            joinColumns = @JoinColumn(name = "user_id"),
            inverseJoinColumns = @JoinColumn(name = "role_id"))
    private Set<Role> roles;


}
